package edu.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.core.StringUtil;
import edu.dao.BaseDao;
import edu.entity.Notice;
import edu.entity.Role;
import edu.entity.User;

@Service("userService")
public class UserService extends BaseService {
	@Autowired
	private BaseDao baseDao;
	
    public void insertUser(User user) throws Exception {
    	if(user!=null){
    		baseDao.insert(user);
    	}
    }
    
    public void updatetUser(User user) throws Exception {
    	if(user!=null){
    		baseDao.update(user);
    	}
    }
    
    public void deleteUser(User user) throws Exception {
    	if(user!=null){
    		baseDao.delete(user);
    	}
    }
    
    public void deleteUserById(String id) throws Exception {
    	if(StringUtil.isNotEmpty(id)){
    		baseDao.deleteById(User.class, id);
    	}
    }
    
    public User selectUserById(String id) throws Exception {
    	
    	User user = null;
    	if(StringUtil.isNotEmpty(id)){
    		user = (User)baseDao.selectObjById(User.class, id);
    	}
    	return user;
    }
}
